<script>
	export default {
		onLaunch: function() {
			console.log('直播语音播报系统启动')
			// 初始化全局设置
			this.initGlobalSettings()
		},
		onShow: function() {
			console.log('应用显示')
		},
		onHide: function() {
			console.log('应用隐藏')
		},
		methods: {
			// 初始化全局设置
			initGlobalSettings() {
				try {
					// 检查是否首次启动
					const isFirstLaunch = uni.getStorageSync('isFirstLaunch')
					if (!isFirstLaunch) {
						// 设置默认值
						const defaultSettings = {
							autoPlay: true,
							defaultVolume: 80,
							smartMode: true,
							smartLevel: 85,
							playInterval: 45,
							theme: 'auto',
							language: 'zh-CN'
						}
						uni.setStorageSync('globalSettings', defaultSettings)
						uni.setStorageSync('isFirstLaunch', true)
						
						// 创建默认房间
						const defaultRooms = [
							{
								id: '1',
								name: '我的直播间',
								description: '默认直播间',
								color: 'linear-gradient(135deg, #667eea, #764ba2)',
								isActive: false,
								audioCount: 0,
								memberCount: 1,
								totalPlayTime: 0,
								playCount: 0,
								recentAudios: []
							}
						]
						uni.setStorageSync('roomList', defaultRooms)
						uni.setStorageSync('currentRoom', defaultRooms[0])
					}
				} catch (e) {
					console.error('初始化设置失败:', e)
				}
			}
		}
	}
</script>

<style lang="scss">

page{
	-webkit-user-select: text;
	user-select: text;
}

/* 通用工具类 */
.flex {
	display: flex;
}

.flex-center {
	display: flex;
	align-items: center;
	justify-content: center;
}

.flex-between {
	display: flex;
	justify-content: space-between;
}

.flex-column {
	display: flex;
	flex-direction: column;
}

.text-center {
	text-align: center;
}

.text-right {
	text-align: right;
}

.text-ellipsis {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* 颜色类 */
.text-primary {
	color: #667eea;
}

.text-success {
	color: #2ed573;
}

.text-warning {
	color: #ffa502;
}

.text-danger {
	color: #ff4757;
}

.text-muted {
	color: #999;
}

/* 背景类 */
.bg-primary {
	background: linear-gradient(135deg, #667eea, #764ba2);
}

.bg-success {
	background: linear-gradient(135deg, #2ed573, #1dd1a1);
}

.bg-white {
	background: #fff;
}

/* 边距类 */
.m-0 { margin: 0; }
.m-10 { margin: 10rpx; }
.m-20 { margin: 20rpx; }
.m-30 { margin: 30rpx; }

.p-0 { padding: 0; }
.p-10 { padding: 10rpx; }
.p-20 { padding: 20rpx; }
.p-30 { padding: 30rpx; }

.mt-0 { margin-top: 0; }
.mt-10 { margin-top: 10rpx; }
.mt-20 { margin-top: 20rpx; }
.mt-30 { margin-top: 30rpx; }

.mb-0 { margin-bottom: 0; }
.mb-10 { margin-bottom: 10rpx; }
.mb-20 { margin-bottom: 20rpx; }
.mb-30 { margin-bottom: 30rpx; }

.pt-0 { padding-top: 0; }
.pt-10 { padding-top: 10rpx; }
.pt-20 { padding-top: 20rpx; }
.pt-30 { padding-top: 30rpx; }

.pb-0 { padding-bottom: 0; }
.pb-10 { padding-bottom: 10rpx; }
.pb-20 { padding-bottom: 20rpx; }
.pb-30 { padding-bottom: 30rpx; }

/* 圆角类 */
.rounded {
	border-radius: 12rpx;
}

.rounded-lg {
	border-radius: 16rpx;
}

.rounded-xl {
	border-radius: 20rpx;
}

.rounded-full {
	border-radius: 50%;
}

/* 阴影类 */
.shadow {
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
}

.shadow-lg {
	box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.15);
}

/* 毛玻璃效果 */
.backdrop-blur {
	backdrop-filter: blur(20rpx);
}

/* 动画类 */
.fade-in {
	animation: fadeIn 0.3s ease-in-out;
}

.slide-up {
	animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes slideUp {
	from { 
		opacity: 0;
		transform: translateY(30rpx);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* 按钮样式 */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 20rpx 30rpx;
	border-radius: 12rpx;
	font-size: 28rpx;
	font-weight: 500;
	border: none;
	cursor: pointer;
	transition: all 0.3s;
}

.btn-primary {
	background: linear-gradient(135deg, #667eea, #764ba2);
	color: #fff;
}

.btn-success {
	background: linear-gradient(135deg, #2ed573, #1dd1a1);
	color: #fff;
}

.btn-outline {
	background: transparent;
	border: 2rpx solid #667eea;
	color: #667eea;
}

.btn:active {
	transform: scale(0.98);
}

/* 卡片样式 */
.card {
	background: #fff;
	border-radius: 16rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
	overflow: hidden;
}

.card-body {
	padding: 30rpx;
}

.card-header {
	padding: 30rpx;
	border-bottom: 1rpx solid #f0f0f0;
	font-weight: 600;
}

/* 加载态 */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 50rpx;
	color: #999;
}

/* 空状态 */
.empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 100rpx 50rpx;
	text-align: center;
}

.empty-icon {
	font-size: 100rpx;
	margin-bottom: 30rpx;
	opacity: 0.3;
}

.empty-title {
	font-size: 32rpx;
	color: #333;
	margin-bottom: 15rpx;
}

.empty-desc {
	font-size: 26rpx;
	color: #999;
}

/* 响应式字体 */
.title-xl {
	font-size: 40rpx;
	font-weight: 600;
}

.title-lg {
	font-size: 36rpx;
	font-weight: 600;
}

.title-md {
	font-size: 32rpx;
	font-weight: 600;
}

.title-sm {
	font-size: 28rpx;
	font-weight: 600;
}

.text-lg {
	font-size: 30rpx;
}

.text-md {
	font-size: 28rpx;
}

.text-sm {
	font-size: 26rpx;
}

.text-xs {
	font-size: 24rpx;
}
</style>
